<template>
  <div class="userCollectItem" @click="toCookbook">
    <div
      class="left"
      :style="{ backgroundImage: `url(${item.thumb_path})` }"
    ></div>
    <div class="right">
      <div class="name">{{ item.n }}</div>
      <div class="seen">{{ item.recommend_label }}</div>
      <div class="author">
        <div class="avatar">
          <div class="avatar">
            <van-image
              round
              width="18px"
              height="18px"
              :src="item.a.p"
              lazy-load
            />
          </div>
        </div>
        <div class="nickname">{{ item.a.n }}</div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import router from "@/router";

const props = defineProps(["item"]);

const toCookbook = () => {
  // console.log("toCookbook");
  router.push({
    path: "/cookbook",
    query: { id: props.item.id, user_id: props.item.a.id },
  });
};
</script>

<style lang="scss" scoped>
.userCollectItem {
  margin-bottom: 15px;
  display: flex;
  cursor: pointer;

  .left {
    height: 122px;
    width: 174px;
    flex-shrink: 0;
    border-radius: 10px;
    background-position: center center;
    background-repeat: no-repeat;
    background-size: 120%;
  }

  .right {
    display: flex;
    flex-direction: column;
    justify-content: center;
    margin-left: 10px;

    .name {
      font-size: 14px;
      margin-bottom: 8px;
    }

    .seen {
      font-size: 12px;
      margin-bottom: 15px;
    }

    .author {
      display: flex;
      align-items: center;

      .avatar {
        width: 18px;
        height: 18px;
        margin-right: 5px;
      }

      .nickname {
        line-height: 18px;
        font-size: 14px;
        color: #999;
      }
    }
  }
}
</style>
